{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "# Install FuxiCTR\n",
    "\n",
    "```{note}\n",
    "The tutorial is for FuxiCTR v1.1.\n",
    "```\n",
    "\n",
    "FuxiCTR has the following requirements.\n",
    "\n",
    "+ python 3.6\n",
    "+ pytorch v1.0/v1.1\n",
    "+ pyyaml >=5.1\n",
    "+ scikit-learn\n",
    "+ pandas\n",
    "+ numpy\n",
    "+ h5py\n",
    "+ tqdm\n",
    "\n",
    "For pytorch, you can download the appropriate whl file according to your CUDA version from https://download.pytorch.org/whl/torch_stable.html, and install offline. For eaxmple:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install torch-1.0.1.post2-cp36-cp36m-linux_x86_64.whl"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "We recommend to install the above enviornment through Anaconda using [Anaconda3-5.2.0-Linux-x86_64.sh](https://link.zhihu.com/?target=https%3A//mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.2.0-Linux-x86_64.sh). Then update the PyYAML version as follows."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!pip install --ignore-installed pyyaml==5.1"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "There are two ways to install FuxiCTR v1.1.x\n",
    "\n",
    "**Solution 1**: pip install (note that all dependent requirements need to be installed accordingly.)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "scrolled": false
   },
   "outputs": [],
   "source": [
    "!pip install fuxictr==1.1.*"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "**Solution 2**: git clone or download the zip file: https://github.com/xue-pai/FuxiCTR/tags\n",
    "\n",
    "If you download the source code, you need to add the fuxictr folder to the system path in your code."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "import sys\n",
    "sys.path.append('./YOUR_PATH_TO_FuxiCTR')"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Check if fuxictr has been installed successfully."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "import fuxictr\n",
    "fuxictr.__version__"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Run the tests:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "!cd tests\n",
    "!bash test_all.sh"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.5"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
